/**
 * Copyright &copy; 2012-2016 <a href="https://www.kaaction.com">KAA</a> All rights reserved All rights reserved.
 */
package com.kaaction.modules.mer.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kaaction.common.persistence.Page;
import com.kaaction.common.service.CrudService;
import com.kaaction.modules.mer.entity.MerCustomer;
import com.kaaction.modules.mer.dao.MerCustomerDao;

/**
 * 客户管理Service
 * @author huanghaiming
 * @version 2017-05-17
 */
@Service
@Transactional(readOnly = true)
public class MerCustomerService extends CrudService<MerCustomerDao, MerCustomer> {

	public MerCustomer get(String id) {
		return super.get(id);
	}
	
	public List<MerCustomer> findList(MerCustomer merCustomer) {
		return super.findList(merCustomer);
	}
	
	public Page<MerCustomer> findPage(Page<MerCustomer> page, MerCustomer merCustomer) {
		return super.findPage(page, merCustomer);
	}
	
	@Transactional(readOnly = false)
	public void save(MerCustomer merCustomer) {
		super.save(merCustomer);
	}
	
	@Transactional(readOnly = false)
	public void delete(MerCustomer merCustomer) {
		super.delete(merCustomer);
	}

	@Transactional(readOnly = false)
	public void updOrInsCustomer(MerCustomer merCustomer) {


		int cnt = super.dao.selctCnt(merCustomer.getThirdpartyId());
		
		if(cnt==0){
			merCustomer.preInsert();
			super.dao.insert(merCustomer);
		}else{
			super.dao.updateCustomer(merCustomer);
		}
		
	}

	@Transactional(readOnly = false)
	public void updateWeddingBudget(MerCustomer merCustomer) {
		super.dao.updateWeddingBudget(merCustomer);
		
	}
	
}